package samoloty.view;

import java.awt.Color;
import java.awt.Font;
import java.awt.Point;
import java.awt.print.PrinterException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.JScrollPane;
import javax.swing.UIManager;

/**
 *
 * @author borysfan
 */
public class DisplayPanel extends ContentPanel implements IContentPanel {

    public int identity = 6;
    private MyTextArea text;
    private JScrollPane scrollPane;

    public DisplayPanel() {
        super();
        initPanel();
    }

    private void initPanel() {
        text = new MyTextArea();
        text.setColumns(63);
        text.setLineWrap(true);
        text.setRows(20);
        text.setWrapStyleWord(true);
        text.setEnabled(false);
        text.setFocusable(true);
        text.setBorder(null);


        UIManager.put("TextArea.font", new javax.swing.plaf.FontUIResource(new Font("monospaced", Font.PLAIN, 14)));
        scrollPane = new JScrollPane(text);
        scrollPane.setBackground(MyColors.getBlack());
        scrollPane.setBounds(2, 2, this.getWidth() - 4, this.getHeight() - 4);
        setLayout(null);
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

        scrollPane.setBorder(null);
        add(scrollPane);


    }

    public void reset() {
    }

    public String getText() {
        return text.getText();
    }

    public void setText(String s) {
        text.setText(s);
        text.setCaretPosition(0);
    }

    public void printPage() {
        try {
            text.print();
        } catch (PrinterException ex) {
            System.err.println("DisplayPanel. Blad podczas drukowania.");
        }
    }

    public void setFirstFieldActive() {
        text.requestFocus();
    }

    @Override
    public int getIdentity() {
        return identity;
    }

    public void firstFocused() {
        text.requestFocus();
    }
}
